import org.junit.jupiter.api.Test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Calendar;
import java.util.Date;

public class test {


    @Test
    public void test1() throws ParseException {



        Date date = new Date();

        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String format = formatter.format(date);
        Date date2 = new Date();

        long time = date.getTime();
        long time2 = date.getTime();
        System.out.println(format);
        System.out.println(time);
        System.out.println(time2);




        LocalDate now = LocalDate.now();
        LocalDate plus = now.plusDays(2);

        LocalTime max = LocalTime.MAX;
        LocalDateTime end = LocalDateTime.of(plus, max);


        System.out.println("----------------------------------------------");




    }

    @Test
    public void test02() throws ParseException {

        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String str="2011-08-23 00:00:00";

        Date dt=sdf.parse(str);

        long time = dt.getTime();
        System.out.println("time："+time);
        Calendar rightNow = Calendar.getInstance();

        rightNow.setTime(dt);

        rightNow.add(Calendar.YEAR,-1);//日期减1年

        rightNow.add(Calendar.MONTH,3);//日期加3个月

        rightNow.add(Calendar.DAY_OF_YEAR,10);//日期加10天
        rightNow.add(Calendar.HOUR,10);//日期加10天

        Date dt1=rightNow.getTime();
        System.out.println("dt1："+dt1.getTime());

        String reStr = sdf.format(dt1);

        System.out.println(reStr);


    }
}
